/**
 * Project: Useful Programs <br>
 * Package: mathematics.probability
 */
package org.leumasjaffe.math.probability;

import java.util.Random;

import org.eclipse.jdt.annotation.NonNullByDefault;

import flanagan.analysis.Stat;

/**
 * Class .GammaRV in file GammaRV.java <br>
 * 
 * @author leumasjaffe
 * Created on: Aug 21, 2012
 * 
 */
@NonNullByDefault
public class GammaRV extends AbstractRV {
	private final double alpha;
	private final double beta;

	/**
	 * 
	 */
	public GammaRV(double alpha, double beta) {
		super();
		this.alpha = alpha;
		this.beta = beta;
	}

	/**
	 * @param r
	 */
	public GammaRV(Random r, double alpha, double beta) {
		super(r);
		this.alpha = alpha;
		this.beta = beta;
	}

	/* (non-Javadoc)
	 * @see mathematics.probability.AbstractRV#getEV()
	 */
	@Override
	public double getEV() {
		return this.alpha/this.beta;
	}

	/* (non-Javadoc)
	 * @see mathematics.probability.AbstractRV#getVar()
	 */
	@Override
	public double getVar() {
		return getEV()/this.beta;
	}

	/* (non-Javadoc)
	 * @see mathematics.probability.AbstractRV#getP(double)
	 */
	@Override
	public double getP(double x) {
		return Stat.gammaPDF(0, this.beta, this.alpha, x);
	}

	/* (non-Javadoc)
	 * @see mathematics.probability.AbstractRV#calcX(double)
	 */
	@Override
	public double calcX(double p) {
		return 0;
	}

	/* (non-Javadoc)
	 * @see mathematics.probability.AbstractRV#getF(double)
	 */
	@Override
	public double getF(double x) {
		return Stat.gammaCDF(0, this.beta, this.alpha, x);
	}

}
